package engine.data
{
	import engine.net.datatype.ByteArrayEx;
	
	import flash.events.IEventDispatcher;
	
	public class View extends ObjectData
	{		
		static public const VIEWPORT_EQUIP 		:Number = 1;	
		
		static public const VIEWPORT_TOOL			:Number = 2;	//道具栏
		static public const VIEWPORT_DEPOT		:Number = 3;	//仓库栏
		
		static public const VIEWPORT_SKILL		:Number = 4;	//技能容器
		
		static public const VIEWPORT_STORE		:Number = 5;	//存储仓库
		
		static public const VIEWPORT_BUFFER		:Number = 6;	//BUFFER容器
		
		//static public const VIEWPORT_PET			:Number = 5;	//宠物拦
		//static public const VIEWPORT_RIDE			:Number = 7;	//骑乘拦
		
		static public const VIEWPORT_BAG			:Number = 8;	//附加的包裹栏		
		static public const VIEWPORT_IDENTIFY		:Number = 9;	//装备鉴定栏		
		static public const VIEWPORT_EQUIPUPGRADE	:Number = 10;	//装备升级栏
		static public const VIEWPORT_ADDSTAR		:Number = 11;	//加星栏
		static public const VIEWPORT_ENCHASE		:Number = 12;	//镶嵌栏
		static public const VIEWPORT_ADDHOLE		:Number = 13;	//打孔栏
		static public const VIEWPORT_COMPOSE		:Number	= 32;	//合成栏
		static public const VIEWPORT_UNENCHASE	:Number	= 33;	//拆除栏
		static public const VIEWPORT_KEEPWORTH	:Number	= 106;	//装备保值
		static public const VIEWPORT_RANDOMSTONE:Number	= 107;//洗宝石
		
		static public const VIEWPORT_ADDMAGIC		:Number = 14;	//附魔栏
		static public const VIEWPORT_ADDMAGICUPGRADE :Number = 15;	//附魔升级栏
		static public const VIEWPORT_REBUILD			:Number = 16;	//改造栏
		static public const VIEWPORT_EQUIPSIGN		:Number = 17;	//装备签名栏
		static public const VIEWPORT_BIND				:Number = 18;	//物品绑定操作栏
		static public const VIEWPORT_RELINK			:Number = 19;	//物品五行、灵魂锁链重置的操作栏
		
		static public const VIEWPORT_SELFEXCHANGE		:Number = 20;	//自己的交换栏
		static public const VIEWPORT_OTHEREXCHANGE	:Number = 21;	//其他玩家的交换栏
		
		static public const VIEWPORT_SELFSHOP			:Number = 22;	//自己的出售栏
		static public const VIEWPORT_OTHERSHOP		:Number = 23;	//其他玩家的出售栏
		
		static public const VIEWPORT_GOODSBOURSE		:Number = 24;	//物品寄卖栏
		static public const VIEWPORT_REBUILD_REPAIR 	:Number = 25;	//装备改造修复
		static public const VIEWPORT_REDEEM           :Number = 26;  //商店赎回栏
		static public const VIEWPORT_POCKETSTORE		:Number = 30;	//随身商店
		
		static public const VIEWPORT_EQUIPBLESS		:Number = 40;	//装备祝福栏
		static public const VIEWPORT_EQUIPTRANSLATE	:Number = 41;	//装备转换栏
		static public const VIEWPORT_PROPERTYCHANGE 	:Number = 42;	//属性转换
		
		//static public const VIEWPORT_SEND_LETTER    :Number = 50;   //发送邮件
		//static public const VIEWPORT_RECEIVE_LETTER	:Number = 51;   //接受邮件
		
		//static public const VIEWPORT_ATTACHSKILL	:Number = 62;	//附身技能容器
		//static public const VIEWPORT_PET_SKILL		:Number = 63;	//当前宠物技能容器
		//static public const VIEWPORT_PET_ATTACHSKILL:Number = 64;	//当前宠物附身技能容器
		//static public const VIEWPORT_PET_EQUIP		:Number = 65;	//当前宠物的装备容器
		static public const VIEWPORT_EQUIP_SKILL		:Number = 66;	//装备技能容器
		static public const VIEWPORT_NATION_SKILL   	:Number = 67;   //国家技能容器
		//static public const VIEWPORT_PETEGG_GROW	:Number = 68;   //宠物蛋升级视图
		
		static public const VIEWPORT_NPCTRADE			:Number = 90;	//NPC交易栏
		
		static public const VIEWPORT_GENIUSSKILL1		:Number = 101;	//天赋容器1
		static public const VIEWPORT_GENIUSSKILL2		:Number = 102;	//天赋容器2
		static public const VIEWPORT_GENIUSSKILL3		:Number = 103;	//天赋容器3		
		static public const VIEWPORT_LIFESKILL	    :Number = 104;	//生活技能容器
		//static public const VIEWPORT_CONJURESKILL	:Number = 105;	//召唤兽的技能	
		static public const VIEWPORT_PARTNER		:Number= 108;	//伙伴
		static public const VIEWPORT_RETIRE_PARTNER:Number			= 430;	//退役伙伴容器(归队用)
		static public const VIEWPORT_KUNGFU		:Number			= 431;	// 功法装备容器
		static public const VIEWPORT_KUNGFUTOOL		:Number		= 432;	// 功法存放容器
		
		static public const VIRWPORT_PET:Number					= 612; //宠物容器
		
		static public const VIEWFAMILY_SHOP:Number				= 613;//帮派商人容器

		public  var _nViewId:uint	=	0;
		private var _nType:uint	=	0;
		private var _nCapacity:uint=	0;
			
		
		public function View(nViewId:uint,nType:uint,nCapacity:uint,target:IEventDispatcher=null) 
		{
			_nViewId 	= 	nViewId;
			_nType	 	= 	nType;
			_nCapacity	= 	nCapacity;
			super(null,"View"+nViewId);
		}		
		
		public function ViewAdd(nObjectId:int,nCount:uint,msg:ByteArrayEx):void
		{
//			IO.traceLog("View add",_nViewId,nObjectId);
			var		tobj:ObjectData	= 	new ViewObject(this,String(nObjectId));
			tobj.setPropertiesFormByteArrayEx(nCount,msg);
			
			HandlePropertiesEx(String(nObjectId),tobj);				
		}
		
		public function ViewRemove(nObjectId:uint):void
		{
			if(CheckProperties(String(nObjectId)))
			{
				DeletePropertiesEx(String(nObjectId));
			}				
		}
		
		public function ViewObjProperty(nObjectId:uint,nCount:uint,msg:ByteArrayEx):void
		{
			if(CheckProperties(String(nObjectId)))
			{
				var		curscene:Scene	=	ModelLocator.getInstance().scene;
				var		tobj:ViewObject	= GetProperties(String(nObjectId));
				tobj.setPropertiesFormByteArrayEx(nCount,msg);
				
				UpdataPropertiesEx(String(nObjectId),tobj);
			
//				HandlePropertiesEx(String(nObjectId),tobj);
			}
		}	
		
		public function Clear():void
		{
			//清掉视图内容
			this.clearProperties();
			//GC.gc();
			//IO.traceLog("View" + _nViewId," Clear");
		}
	}
}